package com.lfnyxy.service.imp;

import com.lfnyxy.dao.PolicyTypeDao;
import com.lfnyxy.dto.DropVo;
import com.lfnyxy.entity.PolicyTypeEntity;
import com.lfnyxy.query.PolicyTypeQuery;
import com.lfnyxy.service.PolicyTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PolicyTypeServiceImp implements PolicyTypeService {
    @Autowired
    public PolicyTypeDao policyTypeDao;

    public int CreateItem(PolicyTypeEntity entity) {
        if (entity != null) {
            return policyTypeDao.CreateItem(entity);
        } else {
            return 0;
        }
    }

    public int UpdateItem(PolicyTypeEntity entity) {
        if (entity != null) {
            return policyTypeDao.UpdateItem(entity);
        } else {
            return 0;
        }
    }

    public List <PolicyTypeEntity> QueryPageList(PolicyTypeQuery query) {
        int count = policyTypeDao.QueryPageListCount(query);
        query.setTotal(count);
        return policyTypeDao.QueryPageList(query);
    }

    public List <PolicyTypeEntity> QueryAll() {
        return policyTypeDao.QueryAll();
    }

    public PolicyTypeEntity QueryItem(int Id) {
        if (Id > 0) {
            return policyTypeDao.QueryItem(Id);
        } else {
            return null;
        }
    }

    public int DeleteItem(int Id) {
        if (Id > 0) {
            return policyTypeDao.DeleteItem(Id);
        } else {
            return 0;
        }
    }

    @Override
    public List <DropVo> QueryDrop(PolicyTypeQuery query) {
        return policyTypeDao.QueryDrop(query);
    }

    private boolean CheckIsExist(PolicyTypeEntity entity) {
        if (entity != null) {
            return policyTypeDao.CheckIsExist(entity) > 0;
        } else {
            return false;
        }
    }
}